//
//  BaseDetailButtomView.swift
//  OverseasOnlineShopping
//
//  Created by 唐先才 on 16/3/10.
//  Copyright © 2016年 唐先才. All rights reserved.
//

import UIKit

class BaseDetailButtomView: UIView {

    override init(frame: CGRect) {
        super.init(frame: frame)
        createUI()
    }

    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
    }
    
    func createUI() {
        let imgArray = ["praise_gray", "collect_gray", "cart_gray"]
        let sImgArray = ["praise_red", "collect_red", "cart_red"]
        for index in 0..<3 {
            let button = UIButton(type: .Custom)
            button.frame = CGRect(x: CGFloat(index) * (frame.size.width) / 4.0, y: 0, width: frame.size.width / 4.0, height: 20)
            button.setImage(UIImage(named: imgArray[index]), forState: .Normal)
            button.setImage(UIImage(named: sImgArray[index]), forState: .Selected)
            button.tag = 1000 + index
            button.addTarget(self, action: "clickAction:", forControlEvents: .TouchUpInside)
            let label = UILabel(frame: CGRect(x: CGFloat(index) * (frame.size.width) / 4.0, y: 20, width: (frame.size.width) / 4.0, height: 20))
            label.textAlignment = NSTextAlignment.Center
            label.font = UIFont.systemFontOfSize(11)
            if index == 0 {
                label.text = "赞"
            } else if index == 1 {
                label.text = "收藏"
            } else {
                label.text = "购物车"
            }
            addSubview(button)
            addSubview(label)
        }
        let goBtn = UIButton(type: .Custom)
        goBtn.frame = CGRect(x: CGFloat(3) * (frame.size.width) / 4, y: 0, width: frame.size.width / 4, height: 44)
        goBtn.backgroundColor = UIColor.orangeColor()
        goBtn.setTitle("立即购买", forState: .Normal)
        goBtn.addTarget(self, action: "goBuy", forControlEvents: .TouchUpInside)
        addSubview(goBtn)
        
        userInteractionEnabled = true
    }
    
    func clickAction(button: UIButton) {
        
    }
    
    func goBuy(button: UIButton) {
        
    }
}
